package com.bigshark.amine_admin.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bigshark.amine_admin.sys.mapper.SysConfigMapper;
import com.bigshark.amine_admin.sys.model.SysConfig;
import com.bigshark.amine_admin.sys.service.SysConfigService;
import com.bigshark.common.utills.PageUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig> implements SysConfigService {
    @Override
    public PageUtils queryList(Map<String, Object> params) {
        String paramKey = (String)params.get("paramKey");
        Integer p = (Integer) params.get("page");
        Integer size = (Integer) params.get("size");
        Page<SysConfig> page = new Page<>(p,size);
        QueryWrapper<SysConfig> wrapper = new QueryWrapper<>();
        wrapper.like(StringUtils.isNotBlank(paramKey),"param_key", paramKey);
        wrapper.eq("status", 1);
        wrapper.orderByDesc("id");
        IPage<SysConfig> data = baseMapper.selectPage(page,wrapper);
        return new PageUtils(data);
    }
}
